<html>
<head><meta charset="utf-8"><title>issue-51027-closure-region-errors · t-compiler/wg-nll · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/index.html">t-compiler/wg-nll</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html">issue-51027-closure-region-errors</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="129944949"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/129944949" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#129944949">(Jul 19 2018 at 17:33)</a>:</h4>
<p><span class="user-mention" data-user-id="116107">@David Wood</span> so I was thinking about <a href="https://github.com/rust-lang/rust/issues/51027" target="_blank" title="https://github.com/rust-lang/rust/issues/51027">#51027</a> and what error to print</p>



<a name="129945013"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/129945013" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#129945013">(Jul 19 2018 at 17:34)</a>:</h4>
<p>I sorta like something like this</p>
<div class="codehilite"><pre><span></span>error: borrowed data cannot be stored outside of its closure
  --&gt; issue-45983.rs:17:27
   |
16 |     let mut x = None;
   |         ----- `x` is declared here, outside of the closure body
17 |     give_any(|y| x = Some(y));:
   |               -  ^^^^^^^^^^^ `y` escapes the closure body here
   |               |
   |               `y` is a reference that is only valid in the closure body
</pre></div>



<a name="129945015"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/129945015" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#129945015">(Jul 19 2018 at 17:34)</a>:</h4>
<p>anyway I thought I would drop a few notes on how to identify the scenario</p>



<a name="129945016"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/129945016" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#129945016">(Jul 19 2018 at 17:34)</a>:</h4>
<p>I guess we can fine-tune the wording in the PR etc</p>



<a name="129945027"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/129945027" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#129945027">(Jul 19 2018 at 17:34)</a>:</h4>
<p>Yeah, I think that is a pretty clear error.</p>



<a name="129945056"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/129945056" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#129945056">(Jul 19 2018 at 17:35)</a>:</h4>
<p>You mentioned how to identify the scenario briefly in the existing notes w/r/t what sub, sup and the most interesting constraint should be.</p>



<a name="129945113"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/129945113" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#129945113">(Jul 19 2018 at 17:36)</a>:</h4>
<p>oh, right, I did, cool</p>



<a name="129945173"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/129945173" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#129945173">(Jul 19 2018 at 17:37)</a>:</h4>
<p>this may take some refactoring, looking more at the code</p>



<a name="129945216"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/129945216" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#129945216">(Jul 19 2018 at 17:38)</a>:</h4>
<p>right now, when we add a label like "let's call the lifetime of this reference <code>'1</code>"</p>



<a name="129945221"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/129945221" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#129945221">(Jul 19 2018 at 17:38)</a>:</h4>
<p>we have code that both searches <em>and</em> adds the label to the diagnostic</p>



<a name="129945224"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/129945224" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#129945224">(Jul 19 2018 at 17:38)</a>:</h4>
<p>I was wondering if that was the right approach</p>



<a name="129945226"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/129945226" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#129945226">(Jul 19 2018 at 17:38)</a>:</h4>
<p>it is convenient because it lets us handle many kinds of scenarios</p>



<a name="129945234"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/129945234" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#129945234">(Jul 19 2018 at 17:38)</a>:</h4>
<p>but if we want to tweak the langage -- e.g., to say something like "this reference is only valid during the closure body"</p>



<a name="129945241"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/129945241" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#129945241">(Jul 19 2018 at 17:39)</a>:</h4>
<p>it's a bit annoying</p>



<a name="129945248"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/129945248" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#129945248">(Jul 19 2018 at 17:39)</a>:</h4>
<p>might be nicer if we passed things back up -- e.g., I found the lifetime at this span etc</p>



<a name="129945253"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/129945253" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#129945253">(Jul 19 2018 at 17:39)</a>:</h4>
<p>though I guess we can pass <em>down</em> a flavor as well</p>



<a name="129945257"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/129945257" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#129945257">(Jul 19 2018 at 17:39)</a>:</h4>
<p>Makes sense.</p>



<a name="129945542"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/129945542" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#129945542">(Jul 19 2018 at 17:44)</a>:</h4>
<p>ok I <a href="https://github.com/rust-lang/rust/issues/51027#issuecomment-406358994" target="_blank" title="https://github.com/rust-lang/rust/issues/51027#issuecomment-406358994">wrote some additional notes here</a></p>



<a name="129945885"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/129945885" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#129945885">(Jul 19 2018 at 17:51)</a>:</h4>
<p>Great, thanks.</p>



<a name="129951287"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/129951287" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#129951287">(Jul 19 2018 at 19:30)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> Am I right in thinking that <code>-Z dump-mir=all</code> should output a <code>.dot</code> file?</p>



<a name="129951561"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/129951561" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#129951561">(Jul 19 2018 at 19:35)</a>:</h4>
<p>Hmm, seems like something strange to do with <code>RUST_LOG</code> and piping the output of rustc into <code>less</code> meant that it didn't output it.</p>



<a name="129951563"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/129951563" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#129951563">(Jul 19 2018 at 19:35)</a>:</h4>
<p>Anyway..</p>



<a name="129951924"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/129951924" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#129951924">(Jul 19 2018 at 19:41)</a>:</h4>
<p>weird</p>



<a name="130010390"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130010390" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130010390">(Jul 20 2018 at 17:05)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> I've submitted <a href="https://github.com/rust-lang/rust/issues/52572" target="_blank" title="https://github.com/rust-lang/rust/issues/52572">#52572</a> that has the bulk of the issue solved. There are two tests mentioned in the issue that it doesn't yet handle and there's a note I've added for a change that I wasn't sure about. I had a blast working on this one, not sure why.</p>



<a name="130010402"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130010402" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130010402">(Jul 20 2018 at 17:05)</a>:</h4>
<p>I don't know if it passes all the tests, I only ran the <code>ui</code> ones locally.</p>



<a name="130013967"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130013967" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130013967">(Jul 20 2018 at 18:17)</a>:</h4>
<p>For the <code>issue-7573.rs</code> case that currently isn't working, I understand what is happening, but I don't know how to work out what I want to work out. We've got this mir for the closure:</p>
<div class="codehilite"><pre><span></span>fn remove_package_from_database::{{closure}}(_1: &amp;mut [closure@src/test/ui/borrowck/issue-7573.rs:29:19: 35:6 lines_to_use:&amp;mut std::vec::Vec&lt;&amp;CrateId&gt;], _2: &amp;CrateId) -&gt; (){
    let mut _0: ();                      // return place
    let mut _3: ();
    let mut _4: &amp;mut std::vec::Vec&lt;&amp;CrateId&gt;;
    let mut _5: &amp;CrateId;

    bb0: {
                                         | Live variables on entry to bb0[0]: [_1, _2]
        StorageLive(_4);                 // bb0[0]: scope 0 at src/test/ui/borrowck/issue-7573.rs:32:9: 32:21
                                         | Live variables on entry to bb0[1]: [_1, _2]
        _4 = &amp;mut (*((*_1).0: &amp;mut std::vec::Vec&lt;&amp;CrateId&gt;)); // bb0[1]: scope 0 at src/test/ui/borrowck/issue-7573.rs:32:9: 32:21
                                         | Live variables on entry to bb0[2]: [_2, _4]
        StorageLive(_5);                 // bb0[2]: scope 0 at src/test/ui/borrowck/issue-7573.rs:32:27: 32:39
                                         | Live variables on entry to bb0[3]: [_2, _4]
        _5 = &amp;(*_2);                     // bb0[3]: scope 0 at src/test/ui/borrowck/issue-7573.rs:32:27: 32:39
                                         | Live variables on entry to bb0[4]: [_4, _5]
        _3 = const &lt;std::vec::Vec&lt;T&gt;&gt;::push(move _4, move _5) -&gt; [return: bb2, unwind: bb1]; // bb0[4]: scope 0 at src/test/ui/borrowck/issue-7573.rs:32:9: 32:40
        // ...more stuff...
</pre></div>


<p>In the above mir, <code> _3 = const &lt;std::vec::Vec&lt;T&gt;&gt;::push(move _4, move _5)</code> is the problematic line, it's trying to push <code>_5</code> into <code>_4</code> which won't work. <code>_4</code> is a mutable borrow of <code>_1</code> which is the captured upvar.</p>
<p>My current code that detects whether we're in an "escaping data" scenario using <code>is_upvar_field_projection</code>. In this case, with a function call, I check whether the receiver is an upvar field projection - ie . it will check whether the place for <code>_4</code> is an upvar using <code>is_upvar_field_projection</code>.</p>
<p>However, <code>_4</code> is a <code>Place::Local(..)</code>, not a <code>Place::Projection(..)</code>. So I'd need to work out (somehow) that <code>_4</code> is just a mutable borrow of <code>_1</code> which I can then check as normal with <code>is_upvar_field_projection</code>. After that, everything just falls out of the rest of the code from earlier commits. I'm not sure how to associate <code>_4</code> with <code>_1</code> to do this check though - I start with <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc/mir/enum.TerminatorKind.html#variant.Call" target="_blank" title="https://doc.rust-lang.org/nightly/nightly-rustc/rustc/mir/enum.TerminatorKind.html#variant.Call">TerminatorKind::Call</a>.</p>



<a name="130037455"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130037455" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130037455">(Jul 21 2018 at 03:43)</a>:</h4>
<p><span class="user-mention" data-user-id="116107">@David Wood</span> that looks awesome!</p>



<a name="130051296"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130051296" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130051296">(Jul 21 2018 at 11:49)</a>:</h4>
<p><span class="user-mention" data-user-id="116107">@David Wood</span> you around by any chance?</p>



<a name="130051375"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130051375" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130051375">(Jul 21 2018 at 11:51)</a>:</h4>
<p>yeah, I'm around.</p>



<a name="130051425"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130051425" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130051425">(Jul 21 2018 at 11:52)</a>:</h4>
<p>cool, I was reviewing your PR and I had a question</p>



<a name="130051447"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130051447" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130051447">(Jul 21 2018 at 11:52)</a>:</h4>
<p>thogh I may have answered it now</p>



<a name="130051516"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130051516" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130051516">(Jul 21 2018 at 11:55)</a>:</h4>
<p>I left a review in any case, mostly a request for some more docs</p>



<a name="130051528"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130051528" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130051528">(Jul 21 2018 at 11:55)</a>:</h4>
<p>your code doesn't trigger on a case like this, right?</p>
<div class="codehilite"><pre><span></span><span class="k">fn</span> <span class="nf">foo</span><span class="p">(</span><span class="n">x</span>: <span class="kp">&amp;</span><span class="nc">mut</span><span class="w"> </span><span class="nb">Vec</span><span class="o">&lt;&amp;</span><span class="kt">u32</span><span class="o">&gt;</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">  </span><span class="n">bar</span><span class="p">(</span><span class="o">|</span><span class="n">y</span><span class="o">|</span><span class="w"> </span><span class="n">x</span><span class="p">.</span><span class="n">push</span><span class="p">(</span><span class="n">y</span><span class="p">));</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">bar</span><span class="p">(</span><span class="n">_</span>: <span class="nc">impl</span><span class="w"> </span><span class="nb">FnOnce</span><span class="p">(</span><span class="o">&amp;</span><span class="kt">u32</span><span class="p">))</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
</pre></div>



<a name="130051535"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130051535" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130051535">(Jul 21 2018 at 11:55)</a>:</h4>
<p>No, that's similar to the <code>issue-7573.rs</code> case I mentioned above.</p>



<a name="130051584"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130051584" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130051584">(Jul 21 2018 at 11:56)</a>:</h4>
<p>ah, ok, I can take a look</p>



<a name="130051587"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130051587" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130051587">(Jul 21 2018 at 11:56)</a>:</h4>
<p>I attempted to add another variant to <code>ConstraintCategory</code> to handle this case but I was struggling to get <code>is_upvar_field_projection</code> to recognize that it was infact a upvar.</p>



<a name="130051594"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130051594" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130051594">(Jul 21 2018 at 11:56)</a>:</h4>
<p>as I mentioned elsewhere I think my desktop in Boston has stopped responding to pings  though :) so it'll take me longer than usual to do a build, since now I have to run on my laptop</p>



<a name="130051597"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130051597" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130051597">(Jul 21 2018 at 11:56)</a>:</h4>
<p>I'm feeling grumpy about it :)</p>



<a name="130051609"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130051609" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130051609">(Jul 21 2018 at 11:57)</a>:</h4>
<p>I work on my laptop all the time, you get used to slow builds.</p>



<a name="130051625"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130051625" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130051625">(Jul 21 2018 at 11:57)</a>:</h4>
<p>heh</p>



<a name="130051632"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130051632" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130051632">(Jul 21 2018 at 11:57)</a>:</h4>
<p>the other thing is having tons of active rust working directories :)</p>



<a name="130051674"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130051674" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130051674">(Jul 21 2018 at 11:58)</a>:</h4>
<p>I am so excited about these new errors though...</p>



<a name="130051776"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130051776" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130051776">(Jul 21 2018 at 12:01)</a>:</h4>
<p>right now my laptop is driving itself crazy trying to build LLVM, for the most part</p>



<a name="130052567"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130052567" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130052567">(Jul 21 2018 at 12:23)</a>:</h4>
<p>FYI pushed a commit that addressed the documentation comments and the function returning an unneccesary <code>Option&lt;..&gt;</code>.</p>



<a name="130052615"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130052615" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130052615">(Jul 21 2018 at 12:24)</a>:</h4>
<p>Checking now whether considering only the first Deref messes with other tests.</p>



<a name="130052619"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130052619" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130052619">(Jul 21 2018 at 12:24)</a>:</h4>
<p>I saw later that it had the same signature as the one for arguments...?</p>



<a name="130052622"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130052622" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130052622">(Jul 21 2018 at 12:24)</a>:</h4>
<p>(I guess that was the original motivation?)</p>



<a name="130052639"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130052639" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130052639">(Jul 21 2018 at 12:25)</a>:</h4>
<p>Yeah, it was. I just added a <code>.map(..)</code> call in that function instead of changing the signature.</p>



<a name="130052960"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130052960" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130052960">(Jul 21 2018 at 12:34)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> Doing a deref only once still causes those duplicate errors:</p>
<div class="codehilite"><pre><span></span>---- [ui] ui/issue-27282-reborrow-ref-mut-in-guard.rs stdout ----
diff of stderr:

+       error[E0596]: cannot borrow immutable item `r` as mutable
+         --&gt; $DIR/issue-27282-reborrow-ref-mut-in-guard.rs:26:40
+          |
+       LL |         ref mut r if { (|| { let bar = &amp;mut *r; **bar = false; })();
+          |                                        ^^^^^^^ cannot borrow as mutable
+
1       error[E0596]: cannot borrow immutable item `*r` as mutable
2         --&gt; $DIR/issue-27282-reborrow-ref-mut-in-guard.rs:26:24
3          |

4       LL |         ref mut r if { (|| { let bar = &amp;mut *r; **bar = false; })();
5          |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot borrow as mutable
6
-       error: aborting due to previous error
+       error: aborting due to 2 previous errors
8
9       For more information about this error, try `rustc --explain E0596`.
10
</pre></div>



<a name="130053069"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130053069" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130053069">(Jul 21 2018 at 12:38)</a>:</h4>
<p>hmm</p>



<a name="130053077"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130053077" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130053077">(Jul 21 2018 at 12:39)</a>:</h4>
<p>ok so ... I think .. those duplicate errors are "correct" in some sense</p>



<a name="130053080"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130053080" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130053080">(Jul 21 2018 at 12:39)</a>:</h4>
<p>well I guess I don't know</p>



<a name="130053124"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130053124" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130053124">(Jul 21 2018 at 12:40)</a>:</h4>
<p>I'm not crazy about the <code>recurse</code> boolean parameter</p>



<a name="130053126"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130053126" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130053126">(Jul 21 2018 at 12:40)</a>:</h4>
<p>but I guess I have to look at the other logic maybe</p>



<a name="130053131"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130053131" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130053131">(Jul 21 2018 at 12:40)</a>:</h4>
<p>right now, it's all the places that are using <code>false</code>, I assume?</p>



<a name="130053145"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130053145" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130053145">(Jul 21 2018 at 12:41)</a>:</h4>
<p>ah so .. ok I think I see the problem</p>



<a name="130053186"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130053186" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130053186">(Jul 21 2018 at 12:42)</a>:</h4>
<p>there is already a "deref" built-in in some of the uses</p>



<a name="130053187"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130053187" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130053187">(Jul 21 2018 at 12:42)</a>:</h4>
<p>e.g. this one</p>
<div class="codehilite"><pre><span></span>             Place::Projection(ref proj) =&gt; {
                 match proj.elem {
                     ProjectionElem::Deref =&gt; {
<span class="gd">-                        if let Some(field) = self.is_upvar_field_projection(&amp;proj.base) {</span>
<span class="gi">+                        let upvar_field_projection = proj.base.is_upvar_field_projection(</span>
<span class="gi">+                            self.mir, &amp;self.tcx, false);</span>
<span class="gi">+                        if let Some(field) = upvar_field_projection {</span>
                             let var_index = field.index();
                             let name = self.mir.upvar_decls[var_index].debug_name.to_string();
                             if self.mir.upvar_decls[var_index].by_ref {
</pre></div>



<a name="130053191"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130053191" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130053191">(Jul 21 2018 at 12:42)</a>:</h4>
<p>if you changed that from <code>proj.base.is_upvar_field_projection</code> to <code>proj.is_upvar_field_projection</code> it would probably work</p>



<a name="130053203"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130053203" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130053203">(Jul 21 2018 at 12:43)</a>:</h4>
<p>some of the other users are a bit less clear but I <em>suspect</em> the <code>*</code> is ok</p>



<a name="130053214"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130053214" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130053214">(Jul 21 2018 at 12:44)</a>:</h4>
<p>that is, handling the deref case is ok</p>



<a name="130053311"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130053311" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130053311">(Jul 21 2018 at 12:46)</a>:</h4>
<p>Ah, I didn't notice that, I'll go check the callsites.</p>



<a name="130053324"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130053324" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130053324">(Jul 21 2018 at 12:46)</a>:</h4>
<p>otoh</p>



<a name="130053327"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130053327" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130053327">(Jul 21 2018 at 12:46)</a>:</h4>
<p>it doesn't seem terrible to split</p>



<a name="130053335"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130053335" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130053335">(Jul 21 2018 at 12:47)</a>:</h4>
<p>i.e., the current method just checks for what it says: <em>is this a field projection</em> (not a deref projection)</p>



<a name="130053336"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130053336" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130053336">(Jul 21 2018 at 12:47)</a>:</h4>
<p>and you could have a wrapper is</p>



<a name="130053339"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130053339" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130053339">(Jul 21 2018 at 12:47)</a>:</h4>
<p><code>is_upvar_ref</code></p>



<a name="130053342"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130053342" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130053342">(Jul 21 2018 at 12:47)</a>:</h4>
<p>that also checks for deref</p>



<a name="130053345"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130053345" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130053345">(Jul 21 2018 at 12:47)</a>:</h4>
<p>if that winds up being useful</p>



<a name="130053349"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130053349" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130053349">(Jul 21 2018 at 12:47)</a>:</h4>
<p>but probably better to just have one :)</p>



<a name="130053403"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130053403" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130053403">(Jul 21 2018 at 12:48)</a>:</h4>
<p>to really know whether the deref is important or not, we'd have to consider the 'mode' of the upvar, which I don't think we currently do?</p>



<a name="130053408"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130053408" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130053408">(Jul 21 2018 at 12:48)</a>:</h4>
<p>that is, you could have <code>x: &amp;mut u32; move || *x</code> and that would desugar to <code>*self.x</code></p>



<a name="130096526"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130096526" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130096526">(Jul 22 2018 at 12:42)</a>:</h4>
<p>Back in the correct topic again... I've done the required rebase, just doing tests locally before pushing.</p>



<a name="130096534"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130096534" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130096534">(Jul 22 2018 at 12:43)</a>:</h4>
<p>ok let me take a look</p>



<a name="130096537"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130096537" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130096537">(Jul 22 2018 at 12:43)</a>:</h4>
<p>I think I almost r+'d yesterday but wanted to see travis results</p>



<a name="130096538"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130096538" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130096538">(Jul 22 2018 at 12:43)</a>:</h4>
<p>then I got distracted</p>



<a name="130096540"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130096540" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130096540">(Jul 22 2018 at 12:43)</a>:</h4>
<p>I'm doing a bit of work this afternoon so I'll be around</p>



<a name="130096543"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130096543" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130096543">(Jul 22 2018 at 12:43)</a>:</h4>
<p>Sounds good. If this PR is still fine then I've got bandwidth to take something else.</p>



<a name="130096578"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130096578" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130096578">(Jul 22 2018 at 12:44)</a>:</h4>
<p>Just pushed the rebase.</p>



<a name="130096594"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130096594" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130096594">(Jul 22 2018 at 12:44)</a>:</h4>
<p>hmm so the question what is best next thing to take on</p>



<a name="130096595"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130096595" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130096595">(Jul 22 2018 at 12:45)</a>:</h4>
<p>I feel like there is more work on region errors</p>



<a name="130096598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130096598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130096598">(Jul 22 2018 at 12:45)</a>:</h4>
<p>if you want to continue in this vein</p>



<a name="130096610"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130096610" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130096610">(Jul 22 2018 at 12:45)</a>:</h4>
<p>they have definitely made many, many strides</p>



<a name="130096619"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130096619" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130096619">(Jul 22 2018 at 12:45)</a>:</h4>
<p>Yeah, we could look into improving some of the cases this PR didn't cover.</p>



<a name="130096693"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130096693" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130096693">(Jul 22 2018 at 12:47)</a>:</h4>
<p>I opened some issues iirc</p>



<a name="130096696"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130096696" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130096696">(Jul 22 2018 at 12:47)</a>:</h4>
<p>one of which had what I thought was an interesting test case to improve</p>



<a name="130096739"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130096739" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130096739">(Jul 22 2018 at 12:48)</a>:</h4>
<p>in general I think things that say "free region requires" is ungreat</p>



<a name="130096828"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130096828" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130096828">(Jul 22 2018 at 12:50)</a>:</h4>
<p>Yeah, those aren't great.</p>



<a name="130097129"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130097129" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130097129">(Jul 22 2018 at 13:00)</a>:</h4>
<p>well I'm marking your PR r+</p>



<a name="130097130"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130097130" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130097130">(Jul 22 2018 at 13:00)</a>:</h4>
<p>if travis gets upset we'll cancel it :)</p>



<a name="130097176"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130097176" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130097176">(Jul 22 2018 at 13:02)</a>:</h4>
<p><span class="user-mention" data-user-id="116107">@David Wood</span> what does your branch do for this example?</p>
<div class="codehilite"><pre><span></span><span class="cp">#![feature(nll)]</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">foo</span><span class="p">(</span><span class="n">_</span>: <span class="nc">impl</span><span class="w"> </span><span class="k">for</span><span class="o">&lt;</span><span class="na">&#39;a</span><span class="o">&gt;</span><span class="w"> </span><span class="nb">FnOnce</span><span class="p">(</span><span class="o">&amp;</span><span class="na">&#39;a</span><span class="w"> </span><span class="kt">u32</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;</span><span class="kt">u32</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="kp">&amp;</span><span class="na">&#39;a</span><span class="w"> </span><span class="kt">u32</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">foo</span><span class="p">(</span><span class="o">|</span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="n">b</span><span class="o">|</span><span class="w"> </span><span class="n">b</span><span class="p">)</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="130097178"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130097178" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130097178">(Jul 22 2018 at 13:02)</a>:</h4>
<p>I am reminded that there were some cases where we wanted to do follow-up</p>



<a name="130097179"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130097179" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130097179">(Jul 22 2018 at 13:02)</a>:</h4>
<p>that example came from <a href="https://github.com/rust-lang/rust/issues/52533" target="_blank" title="https://github.com/rust-lang/rust/issues/52533">https://github.com/rust-lang/rust/issues/52533</a></p>



<a name="130097330"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130097330" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130097330">(Jul 22 2018 at 13:07)</a>:</h4>
<p>Still doing a build (did a check so it needs a full build because of <a href="https://github.com/rust-lang/rust/issues/52565" target="_blank" title="https://github.com/rust-lang/rust/issues/52565">#52565</a>) locally but I'll let you know.</p>



<a name="130098341"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130098341" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130098341">(Jul 22 2018 at 13:42)</a>:</h4>
<p>Seems like my branch didn't have an effect <span class="user-mention" data-user-id="116009">@nikomatsakis</span>:</p>
<div class="codehilite"><pre><span></span>error: unsatisfied lifetime constraints
 --&gt; test1.rs:7:16
  |
7 |     foo(|a, b| b)
  |          -  -  ^ free region requires that `&#39;1` must outlive `&#39;2`
  |          |  |
  |          |  lifetime `&#39;1` appears in this argument
  |          lifetime `&#39;2` appears in this argument
</pre></div>



<a name="130098359"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130098359" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130098359">(Jul 22 2018 at 13:43)</a>:</h4>
<p>ok I expect that is because this is the "return value" case, and I think you disabled your branch in that case...</p>



<a name="130098413"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130098413" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130098413">(Jul 22 2018 at 13:44)</a>:</h4>
<p>I don't think it was explicitly disabled for that case, just that it only handles assignments and function calls.</p>



<a name="130098488"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130098488" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130098488">(Jul 22 2018 at 13:46)</a>:</h4>
<p>ok I see</p>



<a name="130098499"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130098499" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130098499">(Jul 22 2018 at 13:47)</a>:</h4>
<p>well</p>



<a name="130098502"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130098502" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130098502">(Jul 22 2018 at 13:47)</a>:</h4>
<p>this should be an assignment actually</p>



<a name="130098504"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130098504" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130098504">(Jul 22 2018 at 13:47)</a>:</h4>
<p>but an assignment to the "return place"</p>



<a name="130098509"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130098509" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130098509">(Jul 22 2018 at 13:47)</a>:</h4>
<p>(that is, <code>_0</code>)</p>



<a name="130098512"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130098512" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130098512">(Jul 22 2018 at 13:47)</a>:</h4>
<p>if you look at the MIR, you'll see what I mean</p>



<a name="130098515"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130098515" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130098515">(Jul 22 2018 at 13:47)</a>:</h4>
<p>"return slot place"</p>



<a name="130098517"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130098517" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130098517">(Jul 22 2018 at 13:47)</a>:</h4>
<p>we could detect that</p>



<a name="130098518"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130098518" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130098518">(Jul 22 2018 at 13:47)</a>:</h4>
<p>Ah yeah, that's categorized as a <code>Return</code> not an <code>Assignment</code>.</p>



<a name="130098526"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130098526" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130098526">(Jul 22 2018 at 13:47)</a>:</h4>
<p>It'd be pretty easy to support that with the way it's done now.</p>



<a name="130098580"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130098580" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130098580">(Jul 22 2018 at 13:49)</a>:</h4>
<p>do you want to roll that into the same PR?</p>



<a name="130098581"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130098581" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130098581">(Jul 22 2018 at 13:49)</a>:</h4>
<p>or should we do a follow-up</p>



<a name="130098631"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130098631" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130098631">(Jul 22 2018 at 13:50)</a>:</h4>
<p>A new PR is cleaner, but depends if we think that one will land quickly. No point in having another PR waiting for that to land before it can be approved and get in the queue.</p>



<a name="130098786"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130098786" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130098786">(Jul 22 2018 at 13:54)</a>:</h4>
<p>I was gonna p=1 it</p>



<a name="130099324"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130099324" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130099324">(Jul 22 2018 at 14:06)</a>:</h4>
<p>I'll experiment locally with that example see if I can get it to use the newer messages.</p>



<a name="130099856"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130099856" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130099856">(Jul 22 2018 at 14:17)</a>:</h4>
<p>gave p=1 since travis is happy</p>



<a name="130099922"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130099922" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130099922">(Jul 22 2018 at 14:19)</a>:</h4>
<p>I know I keep saying it, but I am quite happy with how these new region errors are turning out :)</p>



<a name="130099924"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130099924" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130099924">(Jul 22 2018 at 14:19)</a>:</h4>
<p>it feels like we're finally getting close to "cracking the case"</p>



<a name="130099941"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130099941" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130099941">(Jul 22 2018 at 14:20)</a>:</h4>
<p>Interestingly, it seems as though the return in that example is being classified as <code>Boring</code>.</p>



<a name="130100018"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130100018" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130100018">(Jul 22 2018 at 14:21)</a>:</h4>
<p>Right now we consider anything that isn't <code>Locations::Interesting</code> as boring. Including <code>Locations::Boring</code> and <code>Locations:All</code> (this example has a combination of both).</p>



<a name="130100035"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130100035" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130100035">(Jul 22 2018 at 14:21)</a>:</h4>
<p>So they aren't even considered for classification as anything more.</p>



<a name="130102457"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130102457" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130102457">(Jul 22 2018 at 15:18)</a>:</h4>
<p>I'd like to remove that distintion, I think, and just move all of that logic into the classificaiton scheme</p>



<a name="130102464"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130102464" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130102464">(Jul 22 2018 at 15:18)</a>:</h4>
<p>maybe we will still need a bit of "pre-logic" though, not sure</p>



<a name="130102469"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130102469" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130102469">(Jul 22 2018 at 15:19)</a>:</h4>
<p>i.e., if the location alone is not enough to distinguish</p>



<a name="130102490"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130102490" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130102490">(Jul 22 2018 at 15:19)</a>:</h4>
<p>It also wasn't being classified correctly as to an upvar because I expected one region to be external and the other local, whereas both were external in this case.</p>



<a name="130103486"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130103486" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130103486">(Jul 22 2018 at 15:43)</a>:</h4>
<p>hmm so actually it's a somewhat different case</p>



<a name="130103487"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130103487" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130103487">(Jul 22 2018 at 15:43)</a>:</h4>
<p>that is, this is not a case of "data local to the region escaping"</p>



<a name="130103489"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130103489" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130103489">(Jul 22 2018 at 15:43)</a>:</h4>
<p>it's just a case of "data with wrong lifetime being returned"</p>



<a name="130103532"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130103532" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130103532">(Jul 22 2018 at 15:44)</a>:</h4>
<div class="codehilite"><pre><span></span>error: borrowed data escapes outside of closure
 --&gt; test1.rs:7:16
  |
7 |     foo(|a, b| b)
  |          -  -  ^ `b` escapes the closure body here
  |          |  |
  |          |  `b` is a reference that is only valid in the closure body
  |          `a` is declared here, outside of the closure body
</pre></div>



<a name="130103536"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130103536" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130103536">(Jul 22 2018 at 15:44)</a>:</h4>
<p>I've got that, using the same labels as before. Not sure what other tests this would effect though.</p>



<a name="130103548"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130103548" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130103548">(Jul 22 2018 at 15:45)</a>:</h4>
<p>well it seems like this message is misleading to me</p>



<a name="130103554"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130103554" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130103554">(Jul 22 2018 at 15:45)</a>:</h4>
<p>I would expect something more like "closure was supposed to return data with lifetime <code>'1</code> but it is returning data with lifetime <code>'2</code>"</p>



<a name="130103561"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130103561" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130103561">(Jul 22 2018 at 15:45)</a>:</h4>
<p>that is, it's not about the data "escaping the closure body"</p>



<a name="130103604"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130103604" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130103604">(Jul 22 2018 at 15:46)</a>:</h4>
<p>Yeah, I didn't adjust the messages at all.</p>



<a name="130103613"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130103613" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130103613">(Jul 22 2018 at 15:46)</a>:</h4>
<p>Was just trying to get it to use that branch of the code.</p>



<a name="130103617"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130103617" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130103617">(Jul 22 2018 at 15:46)</a>:</h4>
<p>my point is I don't think it should use that branch :)</p>



<a name="130103621"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130103621" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130103621">(Jul 22 2018 at 15:46)</a>:</h4>
<p>this seems more like the first branch to me</p>



<a name="130103627"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130103627" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130103627">(Jul 22 2018 at 15:46)</a>:</h4>
<p>or maybe a 3rd branch</p>



<a name="130103635"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130103635" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130103635">(Jul 22 2018 at 15:47)</a>:</h4>
<p>i.e., to me, that branch is about a "local" lifetime escaping into a "global" lifetime</p>



<a name="130103639"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130103639" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130103639">(Jul 22 2018 at 15:47)</a>:</h4>
<p>the other branch is about conflicts between external lifetimes</p>



<a name="130103645"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130103645" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130103645">(Jul 22 2018 at 15:47)</a>:</h4>
<p>in particular, I don't think the message for this case needs to be so different from</p>



<a name="130103649"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130103649" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130103649">(Jul 22 2018 at 15:47)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="k">fn</span> <span class="nf">foo</span><span class="p">(</span><span class="n">x</span>: <span class="kp">&amp;</span><span class="na">&#39;a</span><span class="w"> </span><span class="kt">u32</span><span class="p">,</span><span class="w"> </span><span class="n">y</span>: <span class="kp">&amp;</span><span class="na">&#39;b</span><span class="w"> </span><span class="kt">u32</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="kp">&amp;</span><span class="na">&#39;a</span><span class="w"> </span><span class="kt">u32</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">y</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
</pre></div>



<a name="130103651"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130103651" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130103651">(Jul 22 2018 at 15:47)</a>:</h4>
<p>the message for that case</p>



<a name="130103654"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130103654" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130103654">(Jul 22 2018 at 15:47)</a>:</h4>
<p>I was thinking we should ditch the various <code>ConstraintCategory</code> variants I added that are specific to upvars, and then have branches depending on whether it is a <code>(true, false)</code>, <code>(true, true)</code>, <code>(false, true)</code> and <code>(false, false)</code> pair for the <code>(outlived_fr, fr)</code> being local or not.</p>



<a name="130103702"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130103702" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130103702">(Jul 22 2018 at 15:48)</a>:</h4>
<p>yes, that was my original intent</p>



<a name="130103707"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130103707" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130103707">(Jul 22 2018 at 15:48)</a>:</h4>
<p>I see.</p>



<a name="130103710"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130103710" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130103710">(Jul 22 2018 at 15:48)</a>:</h4>
<p>That does make sense.</p>



<a name="130103712"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130103712" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130103712">(Jul 22 2018 at 15:48)</a>:</h4>
<p>the upvar assignments achieves a similar effect though</p>



<a name="130103715"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130103715" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130103715">(Jul 22 2018 at 15:48)</a>:</h4>
<p>but I think i'd rather do it based on region category ultimately</p>



<a name="130103729"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130103729" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130103729">(Jul 22 2018 at 15:49)</a>:</h4>
<p>(do you want to give that a try in the original PR)</p>



<a name="130103730"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130103730" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130103730">(Jul 22 2018 at 15:49)</a>:</h4>
<p>?</p>



<a name="130103813"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130103813" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130103813">(Jul 22 2018 at 15:51)</a>:</h4>
<p>I'll see what I come up with locally and we can see if the PR has landed by the time I've got anything.</p>



<a name="130103961"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors/near/130103961" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51027-closure-region-errors.html#130103961">(Jul 22 2018 at 15:54)</a>:</h4>
<p>+1</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>